ARC005 C - 器物損壊!高橋君
提出
code: python
from collections import deque
import itertools
h, w = map(int, input().split())
# 2回壊すを全探索?
# print(2500*2499//2) 3123750
for i in itertools.combinations(, 2)
解答
code: python
from collections import deque
h, w = map(int,input().split())
for i in range(h):
for j in range(w):
INF = int(1e9)
# costij はマス (i, j) への最短路長 cost = [INF * w for _ in range(h)] que = deque()
que.append(s)
while que:
nowi, nowj = que.popleft()
if nowi == g0 and nowj == g1: break
nexti, nextj = nowi + i, nowj + j
if nexti < 0 or nexti > h - 1 or nextj < 0 or nextj > w - 1:
continue
# 01-BFS
# 移動先が壁で未到達ならqueの後ろにpush
# 移動先が壁でなく未到達ならqueの先頭にpush
print("YES")
else:
print("NO")
テーマ
メモ
提出
code: python
from collections import deque
h, w = map(int, input().split())
for i in range(h):
for j in range(w):
dis = [0 * w for _ in range(h)] while que:
nowi, nowj = que.popleft()
nexti, nextj = nowi + i, nowj + j
if nexti < 0 or nexti > h-1 or nextj < 0 or nextj > w-1 or disnextinextj != 0 or cnextinextj == "#": continue
else:
print("YES")
else:
# 全通り試す?